<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      
      xmlns:ui="http://java.sun.com/jsf/facelets">
    
    <f:loadBundle basename="br.com.agi.myhome.resource.messages" var="msg"/>
    <h:head>
        <title>${msg.softwareName}</title>
        <link rel="stylesheet" href="#{myHomeUtil.path}/css/set.css" type="text/css" media="all"/>
        <script type="text/javascript" src="#{myHomeUtil.path}/js/validaTecla.js"></script>
    </h:head>   
    <ui:include src="menuPrincipal.xhtml"/>
    <p:panel id="principal" header="${msg.estoque}">
        <h:panelGrid columns="2" columnClasses="menuLateral, conteudo" width="100%">
            <h:form>
                <p:menu>
                    <p:menuitem value="${msg.cadastro}" action="#{cadastroEstoque.apresentarCadastro()}" update="principal" />
                    <p:menuitem value="${msg.listagem}" action="#{cadastroEstoque.apresentarListagem()}" update="principal" />
                </p:menu>
            </h:form>
            <h:form id="cadastro_estoque" rendered="#{controladorEstoque.showCadastro or controladorEstoque.showEdicao}">
                <p:panel styleClass="panelPrime" header="${msg.cadastro_estoque}" >
                    <h:panelGrid columns="2" id="formulario" styleClass="panelPrime"  width="100%">
                        <h:outputText value="${msg.codigo}"/>
                        <p:inputText value="#{cadastroEstoque.estoque.codigo}" id="codigo"
                                    onkeypress=" return validaNumeros(event);">                           
                        </p:inputText>
                        <h:outputText value="${msg.nome}" />
                        <p:inputText value="#{cadastroEstoque.estoque.nome}" 
                                    style="width: 100%;" 
                                    id="descricao"/>                    
                       
                    </h:panelGrid>
                    <h:panelGrid columns="1" 
                                styleClass="buttonsRigth" 
                                style="text-align: right" width="100%" >
                       <p:commandButton action="#{cadastroEstoque.cadastrar}"  update="principal"
                                        value="${msg.cadastrar}" 
                                        rendered="#{controladorEstoque.showCadastro}"/>                        
                        <p:commandButton action="#{cadastroEstoque.salvar}" 
                                        value="${msg.salvar}" 
                                        rendered="#{controladorEstoque.showEdicao}" update="principal"                                        
                                        style="text-align: right;"/>
                    </h:panelGrid>                    

                </p:panel>
                <p:messages autoUpdate="true" showDetail="true"/>
            </h:form> 
            <h:form rendered="#{controladorEstoque.showEstoque}"> 
                 <p:messages autoUpdate="true" showDetail="true"/>
                 <p:dataTable value="#{cadastroEstoque.estoques}" var="estoqueAction" emptyMessage="${msg.sem_registro}">
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="${msg.codigo}"/>
                        </f:facet>
                        <h:outputText value="#{estoqueAction.estoque.codigo}" />
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="${msg.nome}"/>
                        </f:facet>
                        <h:outputText value="#{estoqueAction.estoque.nome}" />
                    </p:column>

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="${msg.comandos}"/>
                        </f:facet>
                        <p:commandButton action="#{estoqueAction.editar}" value="Editar" ajax="false" />
                    </p:column>
                </p:dataTable>
            </h:form>
        </h:panelGrid>        
    </p:panel>
    
</html>
